package com.ms.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum GenderEnum {

    UNSELECTED(0, "未选择", ""),

    MALE(1, "男", "先生"),

    FEMALE(2, "女", "女士");

    private final Integer value;

    private final String description;

    private final String name;

    public static String getDescription(GenderEnum gender) {
        for (GenderEnum genderEnum : values()) {
            if (genderEnum.equals(gender)) {
                return genderEnum.getDescription();
            }
        }
        return "";
    }

    public static GenderEnum getEnumByValue(Integer value) {
        if (value == null) {
            return GenderEnum.UNSELECTED;
        }
        for (GenderEnum genderEnum : values()) {
            if (value.equals(genderEnum.value)) {
                return genderEnum;
            }
        }
        return null;
    }

}
